Method and Apparatus for Controlling Virtual Machine Migration

ABSTRACT

A method and an apparatus for controlling virtual machine (VM) migration is presented, where the method includes obtaining information about an application running on a first VM, where the first VM runs on a first host; determining, according to the information about the application, whether an application associated with the application running on the first VM runs on a second VM, where the second VM is any VM running on a second host; and if no application associated with the application running on the first VM runs on the second VM, migrating the first VM to the second host. The embodiments of the present disclosure can ensure that reliability of an application is not affected during a VM migration process.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/260,409, filed on Sep. 9, 2016, which is a continuation ofInternational Application No. PCT/CN2014/090323 filed on Nov. 5, 2014,which claims priority to Chinese Patent Application No. 201410091247.9filed on Mar. 12, 2014. All of the afore-mentioned patent applicationsare hereby incorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of the present disclosure relate to the field of computertechnologies, and in particular, to a method and an apparatus forcontrolling virtual machine migration.

BACKGROUND

In a virtualization technology, a virtual layer is added betweensoftware and hardware to virtualize a physical machine (PM) at a bottomlayer into multiple virtual machines (VM), and all virtual machines arecentrally scheduled using the virtual layer to implement multiplexing ofthe PM. Virtual machine migration is a main feature of thevirtualization technology. The virtual machine migration refers to thata virtual machine of two or more physical hosts is migrated between thephysical hosts, that is, an operating system and memory data of thevirtual machine, and a status of the virtual machine are transferred ina case of ensuring that an application is not interrupted, whichfeatures zero downtime, and can ensure full utilization of hardwareresources on different physical platforms and improve the operatingefficiency of a system.

Current migration processing of a virtual machine is generallyconsidered from a hardware (for example, a memory or a network)perspective. For example, there is a double-machine application A. In anoriginal situation, a master machine and a slave machine of thedouble-machine application A run on a VM A and a VM B respectively, andthe VM A and the VM B run on a PM A and a PM B respectively. When the PMA is abnormal, an active/standby mechanism is enabled, and the VM Arunning on the PM A is migrated to the PM B by means of a virtualmachine migration operation. In this case, both the VM A and the VM Brun on the PM B. If the PM B becomes abnormal, the active/standbymechanism cannot be enabled, which reduces reliability of theapplication. Similarly, when the application is a cluster application, asimilar problem also exists. If multiple VMs in a same cluster exist onone PM after migration is performed, the reliability of the applicationis also reduced. Therefore, it is necessary to provide a new method toresolve the foregoing problem.

SUMMARY

Embodiments of the present disclosure provide a method and an apparatusfor controlling virtual machine migration, which can ensure thatreliability of an application is not affected during a virtual machinemigration process.

A first aspect of the embodiments of the present disclosure provides anapparatus for controlling virtual machine migration, including anobtaining unit configured to obtain information about an applicationrunning on a first virtual machine, and send the information to adetermining unit, where the first virtual machine runs on a first host;the determining unit configured to receive the information that is aboutthe application running on the first virtual machine and that is sent bythe obtaining unit, and determine, according to the information aboutthe application, whether an application associated with the applicationrunning on the first virtual machine runs on a second virtual machine,and send a result of the determining to a migration control unit, wherethe second virtual machine is any virtual machine running on a secondhost; and the migration control unit configured to receive the result ofthe determining sent by the determining unit, and when the result of thedetermining is that no application associated with the applicationrunning on the first virtual machine runs on the second host, migratethe first virtual machine to the second host.

With reference to the first aspect of the embodiments of the presentdisclosure, in a first implementation manner of the first aspect of theembodiments of the present disclosure, the information that is about theapplication running on the first virtual machine and that is obtained bythe obtaining unit includes a type of the application, where the type ofthe application includes ordinary, double-machine, or cluster.

With reference to the first implementation manner of the first aspect ofthe embodiments of the present disclosure, in a second implementationmanner of the first aspect of the embodiments of the present disclosure,the determining unit includes a first determining unit configured to,when the type of the application running on the first virtual machine isordinary, determine that no application associated with the applicationrunning on the first virtual machine runs on the second virtual machine.

With reference to the first implementation manner of the first aspect ofthe embodiments of the present disclosure, in a third implementationmanner of the first aspect of the embodiments of the present disclosure,when the type of the application running on the first virtual machine isdouble-machine or cluster, the information about the application furtherincludes an identifier of the application; and the determining unitincludes a second determining unit configured to, when the type of theapplication running on the first virtual machine is double-machine orcluster, determine whether an identifier, matching the identifier of theapplication running on the first virtual machine, of an applicationrunning on the second virtual machine exists, and when the identifierdoes not exist, determine that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine.

With reference to the first aspect of the embodiments of the presentdisclosure, the first implementation manner of the first aspect, thesecond implementation manner of the first aspect, or the thirdimplementation manner of the first aspect, in a fourth implementationmanner of the first aspect of the embodiments of the present disclosure,the apparatus further includes a detection unit configured to detect aremaining resource amount of the second host, and send a detectionresult to a trigger unit; and the trigger unit configured to receive thedetection result sent by the detection unit, and when the detectionresult is that the remaining resource amount of the second host isgreater than or equal to a preset threshold, trigger the obtaining unitto obtain the information about the application running on the firstvirtual machine.

A second aspect of the embodiments of the present disclosure provides amethod for controlling virtual machine migration, including obtaininginformation about an application running on a first virtual machine,where the first virtual machine runs on a first host; determining,according to the information about the application, whether anapplication associated with the application running on the first virtualmachine runs on a second virtual machine, where the second virtualmachine is any virtual machine running on a second host; and when noapplication associated with the application running on the first virtualmachine runs on the second virtual machine, migrating the first virtualmachine to the second host.

With reference to the second aspect of the embodiments of the presentdisclosure, in a first implementation manner of the second aspect of theembodiments of the present disclosure, the information about theapplication running on the first virtual machine includes a type of theapplication, where the type of the application includes ordinary,double-machine, or cluster.

With reference to the first implementation manner of the second aspectof the embodiments of the present disclosure, in a second implementationmanner of the second aspect of the embodiments of the presentdisclosure, the determining, according to the information about theapplication, whether an application associated with the applicationrunning on the first virtual machine runs on the second virtual machineincludes, when the type of the application running on the first virtualmachine is ordinary, determining that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine.

With reference to the first implementation manner of the second aspectof the embodiments of the present disclosure, in a third implementationmanner of the second aspect of the embodiments of the presentdisclosure, the determining, according to the information about theapplication, whether an application associated with the applicationrunning on the first virtual machine runs on the second virtual machineincludes, when the type of the application running on the first virtualmachine is double-machine or cluster, and the information about theapplication further includes an identifier of the application,determining whether an identifier, matching the identifier of theapplication running on the first virtual machine, of an applicationrunning on the second virtual machine exists; and when the identifierdoes not exist, determining that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine.

With reference to the second aspect of the embodiments of the presentdisclosure, the first implementation manner of the second aspect, thesecond implementation manner of the second aspect, or the thirdimplementation manner of the second aspect, in a fourth implementationmanner of the second aspect of the embodiments of the presentdisclosure, before obtaining information about an application running ona first virtual machine, the method further includes detecting aremaining resource amount of the second host; and when the remainingresource amount of the second host is greater than or equal to a presetthreshold, triggering the step of obtaining information about anapplication running on a first virtual machine.

It can be seen from the foregoing technical solutions that theembodiments of the present disclosure have the following advantages.

In the embodiments of the present disclosure, information about anapplication running on a first virtual machine is first obtained, wherethe first virtual machine runs on a first host; it is determined,according to the information about the application, whether anapplication associated with the application running on the first virtualmachine runs on a second virtual machine, where the second virtualmachine is any virtual machine running on a second host; and if noapplication associated with the application running on the first virtualmachine runs on the second virtual machine, the first virtual machine ismigrated to the second host. In the embodiments of the presentdisclosure, before the first virtual machine is migrated to the secondhost, it is first determined whether an application associated with theapplication running on the first virtual machine runs on all the virtualmachines running on the second host, and if no application associatedwith the application running on the first virtual machine runs on allthe virtual machines running on the second host, virtual machinemigration is performed. Therefore, different virtual machines on whichan associated application runs are prevented from running on a same hostafter migration is performed, and reliability of an original applicationafter the migration is performed is ensured.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the presentdisclosure more clearly, the following briefly describes theaccompanying drawings required for describing the embodiments or theprior art. The accompanying drawings in the following description showmerely some embodiments of the present disclosure, and a person ofordinary skill in the art may still derive other drawings from theseaccompanying drawings without creative efforts.

FIG. 1 is a schematic diagram of an embodiment of an apparatus forcontrolling virtual machine migration according to the presentdisclosure;

FIG. 2 is a schematic diagram of another embodiment of an apparatus forcontrolling virtual machine migration according to the presentdisclosure;

FIG. 3 is a schematic diagram of another embodiment of an apparatus forcontrolling virtual machine migration according to the presentdisclosure;

FIG. 4 is a schematic diagram of another embodiment of a method forcontrolling virtual machine migration according to the presentdisclosure; and

FIG. 5 is a schematic diagram of another embodiment of a method forcontrolling virtual machine migration according to the presentdisclosure.

DESCRIPTION OF EMBODIMENTS

The following describes the technical solutions in the embodiments ofthe present disclosure with reference to the accompanying drawings inthe embodiments of the present disclosure. The described embodiments aremerely a part rather than all of the embodiments of the presentdisclosure. All other embodiments obtained by a person of ordinary skillin the art based on the embodiments of the present disclosure withoutcreative efforts shall fall within the protection scope of the presentdisclosure.

The embodiments of the present disclosure provide a method and anapparatus for controlling virtual machine migration, which can ensurethat reliability of an application is not affected during a virtualmachine migration process.

Referring to FIG. 1, FIG. 1 is a schematic diagram of an embodiment ofan apparatus for controlling virtual machine migration according to thepresent disclosure. An apparatus 100 for controlling virtual machinemigration in this embodiment includes an obtaining unit 101 configuredto obtain information about an application running on a first virtualmachine, and send the information to a determining unit 102, where thefirst virtual machine runs on a first host; the determining unit 102configured to receive the information that is about the applicationrunning on the first virtual machine and that is sent by the obtainingunit 101, and determine, according to the information about theapplication, whether an application associated with the applicationrunning on the first virtual machine runs on a second virtual machine,and send a result of the determining to a migration control unit 103,where the second virtual machine is any virtual machine running on asecond host; and the migration control unit 103 configured to receivethe result of the determining sent by the determining unit 102, and whenthe result of the determining is that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine, migrate the first virtual machine to the second host.

A host mentioned in this embodiment refers to a computer in whichvirtualization software is used. The computer has a virtual layerbecause of use of the virtualization software, and multiple virtualmachines may run on one host. The host provides resources used by avirtual machine, such as a central processing unit (CPU) and a memory,and allows that the virtual machine can access a memory and a network.

In this embodiment, the first virtual machine runs on the first host,and another virtual machine may further run on the first host. Someapplications may run on the first virtual machine. If an applicationruns on the first virtual machine, the obtaining unit 101 obtains theapplication running on the first virtual machine.

One or more virtual machines may run on the second host, any virtualmachine running on the second host is referred to as the second virtualmachine herein. That is, the first virtual machine refers to a virtualmachine running on the first host, and the second virtual machine refersto any virtual machine running on the second host, where there are oneor more second virtual machines. Some applications may also run on thesecond virtual machine. The obtaining unit 101 may obtain informationabout an application running on the second virtual machine and send theinformation to the determining unit 102, and the determining unit 102determines whether an application associated with the applicationrunning on the first virtual machine runs on the second virtual machine.

If a result of the determining is that the application running on thesecond virtual machine is not associated with the application running onthe first virtual machine, it indicates that after the first virtualmachine is migrated to the second host, reliability of the applicationthat originally runs on the first virtual machine is not affected by themigration. In this case, if the first host becomes faulty, or anothercase in which the first virtual machine needs to be migrated occurs, themigration control unit 103 may migrate the first virtual machine to thesecond host. If the result of the determining is that the applicationrunning on the second virtual machine is associated with the applicationrunning on the first virtual machine, it indicates that after the firstvirtual machine is migrated to the second host, the reliability of theapplication that originally runs on the first virtual machine isaffected by the migration, and then the first virtual machine isrejected to be migrated to the second host.

In addition, if no application runs on the first virtual machine, themigration control unit 103 may directly migrate the first virtualmachine to the second host when there is a need.

In this embodiment, before a migration control unit migrates a firstvirtual machine to a second host, a determining unit first determineswhether an application associated with an application running on thefirst virtual machine runs on all virtual machines running on the secondhost, and if no application associated with the application running onthe first virtual machine runs on all the virtual machines running onthe second host, the migration control unit performs virtual machinemigration. Therefore, different virtual machines on which an associatedapplication runs are prevented from running on a same host aftermigration is performed, and reliability of an original application afterthe migration is performed is ensured.

For ease of understanding, the following describes, using a specificexample, an apparatus for controlling virtual machine migration in anembodiment of the present disclosure. Referring to FIG. 2, an apparatus200 for controlling virtual machine migration in an embodiment includesa detection unit 201 configured to detect a remaining resource amount ofa second host, and send a detection result to a trigger unit 202; thetrigger unit 202 configured to receive the detection result sent by thedetection unit 201, and when the detection result is that the remainingresource amount of the second host is greater than or equal to a presetthreshold, trigger an obtaining unit 203 to obtain information about anapplication running on a first virtual machine; the obtaining unit 203configured to obtain the information about the application running onthe first virtual machine, and send the information to a determiningunit 204, where the first virtual machine runs on a first host; thedetermining unit 204 configured to receive information that is about theapplication running on the first virtual machine and that is sent by theobtaining unit 203, and determine, according to the information aboutthe application, whether an application associated with the applicationrunning on the first virtual machine runs on a second virtual machine,and send a result of the determining to a migration control unit 205,where the second virtual machine is any virtual machine running on thesecond host; and the migration control unit 205 configured to receivethe result of the determining sent by the determining unit 204, and whenthe result of the determining is that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine, migrate the first virtual machine to the second host.

The determining unit 204 includes a first determining unit 2041 and asecond determining unit 2042, where the first determining unit 2041 isconfigured to, when a received type of the application running on thefirst virtual machine is ordinary, determine that no applicationassociated with the application running on the first virtual machineruns on the second virtual machine; and the second determining unit 2042is configured to, when the received type of the application running onthe first virtual machine is double-machine or cluster, determinewhether an identifier, matching an identifier of the application runningon the first virtual machine, of an application running on the secondvirtual machine exists, and if the identifier does not exist, determinethat no application associated with the application running on the firstvirtual machine runs on the second virtual machine.

For further understanding of the apparatus 200 for controlling virtualmachine migration in this embodiment, the following describes, using anactual application scenario, an interactive manner between units of theapparatus 200 for controlling virtual machine migration in thisembodiment.

In this embodiment, the apparatus 200 for controlling virtual machinemigration may control multiple virtual machines on multiple hosts to bemigrated between the hosts, where the multiple hosts include the firsthost and the second host; the first virtual machine refers to a virtualmachine running on the first host, and another virtual machine mayfurther run on the first host; and the second host refers to any virtualmachine running on the second host.

When the first virtual machine on the first host needs to be migrated tothe second host, the detection unit 201 detects a resource usage amountof the second host, where the resources may include a memory, a network,and the like; determines whether the remaining resource amount of thesecond host is greater than or equal to the preset threshold, and sendsa detection result to the trigger unit 202, where the preset thresholdmay be preset by the detection unit 201 according to a resource usageamount of an application running on a virtual machine that needs to bemigrated.

If the detection result received by the trigger unit 202 is that theremaining resource amount of the second host is greater than or equal tothe preset threshold, it indicates that the second host may satisfy amigration requirement of the first virtual machine from a hardwareperspective. Whether the first virtual machine may be migrated to thesecond host further needs to be determined by the determining unit 204from an application perspective. The obtaining unit 203 obtains theinformation about the application running on the first virtual machine.

The information about the application includes a type of theapplication, and the type of the application includes ordinary,double-machine, or cluster. In addition, when the type of theapplication is double-machine or cluster, the information about theapplication further includes an identifier of the application. Theidentifier of the application includes an application name, a nodeidentifier, and the like. An application of an ordinary type existsindependently, and is not associated with another application. For anapplication of a double-machine type, applications are associated witheach other, and may be identified using an application name (used todetermine whether the applications are a same double-machineapplication) and a node identifier (for example, Master or Slave).Initially, associated applications run on virtual machines of twodifferent hosts. Similarly, when an application is a clusterapplication, applications are also associated with each other, and maybe identified using an application name (used to determine whether theapplications are a same cluster application) and a node identifier (forexample, a Node1d, a Node2d, or a Node3d). Initially, associatedapplications run on virtual machines of multiple different hosts. For anapplication of a double-machine type and an application of a clustertype, it is considered that identifiers of two applications match eachother only when both application names and node identifiers match eachother, where the matching herein refers to being the same orcorresponding.

The determining unit 204 determines whether an application associatedwith the application running on the first virtual machine runs on thesecond virtual machine, where when a type, obtained by the obtainingunit 203, of the application running on the first virtual machine isordinary, it indicates that the application exists independently, andthe first determining unit 2041 determines that no applicationassociated with the application runs on all second virtual machines,that is, performing migration on the first virtual machine does notaffect reliability of the application running on the first virtualmachine; the second host may serve as a protection host of the firstvirtual machine running on the first host; when the first host becomesfaulty, or the first virtual machine needs to be migrated in anothersituation, the migration control unit 205 may migrate the first virtualmachine to the second host.

When the type, obtained by the obtaining unit 203, of the applicationrunning on the first virtual machine is double-machine or cluster, whenmigration on the first virtual machine is being performed, for thesecond determining unit 2042, a reliability problem of the applicationthat originally runs on the first virtual machine after the migration isperformed needs to be considered. The second determining unit 2042determines whether the identifier of the application running on thesecond virtual machine matches the identifier of the application runningon the first virtual machine. If the identifier of the applicationrunning on the second virtual machine does not match the identifier ofthe application running on the first virtual machine, the seconddetermining unit 2042 determines that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine. When there is a need, the migration control unit 205may migrate the first virtual machine to the second host. If anidentifier of any application running on a virtual machine on the secondhost matches the identifier of the application running on the firstvirtual machine, it indicates that after the first virtual machine ismigrated to the second host, different virtual machines on which anassociated application runs run on the second host. Migrating the firstvirtual machine to the second host affects the reliability of theapplication that originally runs on the first virtual machine.Considering from an application perspective, the second host is notsuitable for serving as a protection host of the first virtual machine.The migration control unit 205 rejects to migrate the first virtualmachine to the second host.

In this embodiment, when a migration control unit needs to migrate afirst virtual machine to a second host, a detection unit and a triggerunit first determine, from a hardware perspective, whether the secondhost satisfies a migration condition, and then a determining unitdetermines, from an application perspective, whether the second hostsatisfies the migration condition. Only when a remaining resource amountof the second host satisfies a preset condition, and no applicationassociated with an application running on the first virtual machine runson all virtual machines on the second host, the migration control unitmigrates the first virtual machine to the second host. Therefore,different virtual machines on which an associated application runs areprevented from running on a same host after migration is performed, andreliability of an original application after the migration is performedis ensured.

The following further describes an apparatus for controlling virtualmachine migration according to an embodiment of the present disclosure.Referring to FIG. 3, details are as follows.

An apparatus 300 for controlling virtual machine migration may includeparts such as a radio frequency (RF) circuit 310, a memory 320 includingone or more computer-readable storage media, an input unit 330, adisplay unit 340, a sensor 350, an audio frequency circuit 360, a WiFimodule 370, a processor 380 including one or more processing cores, anda power supply 390. A person skilled in the art may understand that astructure shown in FIG. 3 does not constitute any limitation to theapparatus 300, and may include more or less parts than those shown inthe figure, or a combination of some parts, or parts disposeddifferently.

The RF circuit 310 may be configured to receive and send a signal in amessage receiving or sending process, and in particular, after receivingdownlink information of a base station, send the downlink information toone or more processors 380 to perform processing; and in addition, senduplink data to the base station. Generally, the RF circuit 310 includesbut is not limited to an antenna, at least one amplifier, a tuner, oneor more oscillators, a subscriber identity module (SIM) card, atransceiver, a coupler, a low noise amplifier (LNA), and a duplexer. Inaddition, the RF circuit 310 may further communicate with a network andanother device by means of radio communication. Any communicationsstandard or protocol may be used for the radio communication, includingbut not limited to a Global System for Mobile Communications (GSM), ageneral packet radio service (GPRS), Code Division Multiple Access(CDMA), Wideband Code Division Multiple Access (WCDMA), Long TermEvolution (LTE), an email, and a short message service (SMS).

The memory 320 may be configured to store a software program and amodule, and the processor 380 runs the software program and the modulethat are stored in the memory 320, so as to execute various functionsand applications and perform data processing. The memory 320 may mainlyinclude a program storage area and a data storage area, where theprogram storage area may store an operating system, an applicationprogram required by at least one function (such as a voice play functionor an image play function), and the like, and the data storage area maystore data (such as audio data and a phone book) created according touse of the apparatus 300 for controlling virtual machine migration, andthe like. In addition, the memory 320 may include a high-speed randomaccess memory (RAM), and may further include a non-volatile memory, forexample, at least one magnetic disk storage device, a flash memorydevice, or another volatile solid-state storage device. Accordingly, thememory 320 may further include a memory controller to provide access ofthe processor 380 and the input unit 330 to the memory 320.

The input unit 330 may be configured to receive input digital orcharacter information, and generate signal input, obtained using akeyboard, a mouse, a joystick, optics, or a trackball, related to usersetting and function control. The input unit 330 may include atouch-sensitive surface 331 and another input device 332. Thetouch-sensitive surface 331 is also referred to as a touch displayscreen or a touch panel, and may collect a touch operation (such as anoperation performed by a user on the touch-sensitive surface 331 or nearthe touch-sensitive surface 331 using any proper object or accessory,such as a finger or a stylus) performed by the user on or near thetouch-sensitive surface 331, and drive a corresponding connectingapparatus according to a preset program. Optionally, the touch-sensitivesurface 331 may include two parts: a touch detection apparatus and atouch controller. The touch detection apparatus detects a touchorientation of the user, detects a signal brought by the touchoperation, and transfers the signal to the touch controller. The touchcontroller receives touch information from the touch detectionapparatus, converts the touch information into contact coordinates, andsends the contact coordinates to the processor 380, and can receive andexecute a command sent by the processor 380. In addition, thetouch-sensitive surface 331 may be implemented using multiple types,such as a resistive type, a capacitive type, an infrared type, and asurface acoustic wave type. In addition to the touch-sensitive surface331, the input unit 330 may further include the another input device332. The another input device 332 may include but is not limited to oneor more of a physical keyboard, a function key (such as a volume controlkey or a switch key), a trackball, a mouse, and a joystick.

The display unit 340 may be configured to display information input bythe user or information provided for the user, and various graphicaluser interfaces of the apparatus 300 for controlling virtual machinemigration, where the graphical user interfaces may be constituted by agraph, a text, an icon, a video, and any combination thereof. Thedisplay unit 340 may include a display panel 341. Optionally, thedisplay panel 341 may be configured in a form such as a liquid crystaldisplay (LCD) or an organic light-emitting diode (OLED). Further, thetouch-sensitive surface 331 may cover the display panel 341. Whendetecting a touch operation on or near the touch-sensitive surface 331,the touch-sensitive surface 331 transfers the touch operation to theprocessor 380 to determine a type of a touch event, and then theprocessor 380 provides corresponding visual output on the display panel341 according to the type of the touch event. In FIG. 3, thetouch-sensitive surface 331 and the display panel 341 are configured astwo independent parts to implement input and output functions. However,in some embodiments, the touch-sensitive surface 331 and the displaypanel 341 may be integrated to implement the input and output functions.

The apparatus 300 for controlling virtual machine migration may furtherinclude at least one sensor 350, such as a light sensor, a motionsensor, or another sensor. The light sensor may include an ambient lightsensor and a proximity sensor, where the ambient light sensor may adjustluminance of the display panel 341 according to brightness of ambientlight, and the proximity sensor may turn off the display panel 341and/or backlight when the apparatus 300 for controlling virtual machinemigration moves close to an ear. Other sensors such as a gyroscope, abarometer, a hygrometer, a thermometer, and an infrared sensor that mayalso be configured in the apparatus 300 for controlling virtual machinemigration are not described herein.

The audio frequency circuit 360, a loudspeaker 361, and a microphone 362may provide an audio interface between the user and the apparatus 300for controlling virtual machine migration. The audio frequency circuit360 may transmit, to the loudspeaker 361, an electrical signal that isobtained after conversion of received audio data, and the loudspeaker361 converts the electrical signal into a sound signal and outputs thesound signal; in another aspect, the microphone 362 converts a collectedsound signal into an electrical signal, the audio frequency circuit 360receives and converts the electrical signal into audio data and outputsthe audio data to the processor 380 to perform processing, and then theaudio data is sent to, for example, another apparatus, using the RFcircuit 310, or the audio data is output to the memory 320 to performfurther processing. The audio frequency circuit 360 may further includea headset jack to provide communication between a peripheral headset andthe apparatus 300 for controlling virtual machine migration.

WiFi belongs to a short-distance wireless transmission technology. Theapparatus 300 for controlling virtual machine migration may help, usingthe WiFi module 370, the user send and receive an email, browse a webpage, access streaming media, and the like. The WiFi module 370 provideswireless broadband Internet access for the user. Although FIG. 3 showsthe WiFi module 370, it may be understood that the WiFi module 370 isnot a mandatory part of the apparatus 300 for controlling virtualmachine migration, and may completely be omitted as required withoutchanging a scope of the essence of the present disclosure.

The processor 380 is a control center of the apparatus 300 forcontrolling virtual machine migration and is connected to each part ofthe entire apparatus using various interfaces and lines, and performs,by running or executing the software program and/or module that isstored in the memory 320 and invoking data stored in the memory 320,various functions of the apparatus 300 for controlling virtual machinemigration, and data processing, so as to perform overall monitoring onthe apparatus. Optionally, the processor 380 may include one or moreprocessing cores. Preferably, an application processor and a modemprocessor may be integrated into the processor 380, where theapplication processor mainly processes an operating system, a userinterface, an application program, and the like; and the modem processormainly processes radio communication. It may be understood that theforegoing modem processor may also not be integrated into the processor380.

The apparatus 300 for controlling virtual machine migration furtherincludes the power supply 390 (such as a battery) that supplies power toeach part. Preferably, the power supply may be logically connected tothe processor 380 using a power supply management system, so thatfunctions such as management of charging, discharging, and powerconsumption are implemented using the power supply management system.The power supply 390 may further include any component, such as one ormore direct current power supplies or alternating current powersupplies, a recharging system, a power supply fault detection circuit, apower converter or a power inverter, or a power status indicator.

Though not shown, the apparatus 300 for controlling virtual machinemigration may further include a camera, a Bluetooth® module, and thelike, which are not described herein. In this embodiment, the memory 320of the apparatus 300 for controlling virtual machine migration storesone or more programs. The processor 380 runs the software program storedin the memory 320 to obtain information about an application running ona first virtual machine, where the first virtual machine runs on a firsthost; determine, according to the information about the application,whether an application associated with the application running on thefirst virtual machine runs on a second virtual machine, where the secondvirtual machine is any virtual machine running on a second host; and ifno application associated with the application running on the firstvirtual machine runs on the second virtual machine, migrate the firstvirtual machine to the second host.

The information that is about the application running on the firstvirtual machine and that is obtained by the processor 380 includes atype of the application. The type of the application includes ordinary,double-machine, or cluster.

That the processor 380 determines whether an application associated withthe application running on the first virtual machine runs on the secondvirtual machine includes, if the type of the application running on thefirst virtual machine is ordinary, the processor 380 determines that noapplication associated with the application running on the first virtualmachine runs on the second virtual machine; and if the type of theapplication running on the first virtual machine is double-machine orcluster, the information about the application further includes anidentifier of the application, the processor 380 determines whether anidentifier, matching the identifier of the application running on thefirst virtual machine, of an application running on the second virtualmachine exists, and if the identifier does not exist, the processor 380determines that no application associated with the application runningon the first virtual machine runs on the second virtual machine.

Before the processor 380 obtains the application running on the firstvirtual machine, the method further includes detecting a remainingresource amount of the second host; and when the remaining resourceamount of the second host is greater than or equal to a presetthreshold, triggering the step of obtaining the information about theapplication running on the first virtual machine.

It should be noted that, the apparatus 300 for controlling virtualmachine migration according to this embodiment of the present disclosuremay be further configured to implement another function of the foregoingapparatus embodiment, which is not described herein.

In this embodiment, when a processor needs to migrate a first virtualmachine to a second host, it is first considered, from a hardwareperspective, whether the second host satisfies a migration condition,and then it is considered, from an application perspective, whether thesecond host satisfies the migration condition. Only when a remainingresource amount of the second host satisfies a preset condition, and noapplication associated with an application running on the first virtualmachine runs on all virtual machines on the second host, the firstvirtual machine is migrated to the second host. Therefore, differentvirtual machines on which an associated application runs are preventedfrom running on a same host after migration is performed, andreliability of an original application after the migration is performedis ensured.

The following describes a method for controlling virtual machinemigration according to an embodiment of the present disclosure.Referring to FIG. 4, a host mentioned in an embodiment is a computer inwhich virtualization software is used. The computer has a virtual layerbecause of use of the virtualization software, and multiple virtualmachines may run on one host. The host provides resources used by avirtual machine, such as a CPU and a memory, and allows that the virtualmachine can access a memory and a network. The method in this embodimentincludes the following steps.

Step 401: Obtain information about an application running on a firstvirtual machine.

In this embodiment, the first virtual machine runs on a first host, andanother virtual machine may further run on the first host. Someapplications may run on the first virtual machine. If an applicationruns on the first virtual machine, an apparatus for controlling virtualmachine migration obtains the information about the application runningon the first virtual machine.

Step 402: Determine, according to the information about the application,whether an application associated with the application running on thefirst virtual machine runs on a second virtual machine.

One or more virtual machines may run on the second host, any virtualmachine running on the second host is referred to as the second virtualmachine herein. That is, the first virtual machine refers to a virtualmachine running on the first host, and the second virtual machine refersto any virtual machine running on the second host, where there are oneor more second virtual machines. Some applications may also run on thesecond virtual machine. The apparatus for controlling virtual machinemigration determines whether an application associated with theapplication running on the first virtual machine runs on the secondvirtual machine.

Step 403: If no application associated with the application running onthe first virtual machine runs on the second virtual machine, migratethe first virtual machine to a second host.

If each application running on the second virtual machine is notassociated with the application running on the first virtual machine, itindicates that after the first virtual machine is migrated to the secondhost, reliability of the application that originally runs on the firstvirtual machine is not affected by the migration. In this case, if thefirst host becomes faulty, or another case in which the first virtualmachine needs to be migrated occurs, the first virtual machine may bemigrated to the second host. If the application running on the secondvirtual machine is associated with the application running on the firstvirtual machine, it indicates that after the first virtual machine ismigrated to the second host, the reliability of the application thatoriginally runs on the first virtual machine is affected by themigration, and then the first virtual machine is rejected to be migratedto the second host.

In addition, if no application runs on the first virtual machine, thefirst virtual machine may be directly migrated to the second host whenthere is a need.

In this embodiment, before a first virtual machine is migrated to asecond host, it is first determined whether an application associatedwith an application running on the first virtual machine runs on allvirtual machines running on the second host, and if no applicationassociated with the application running on the first virtual machineruns on all the virtual machines running on the second host, virtualmachine migration is performed. Therefore, different virtual machines onwhich an associated application runs are prevented from running on asame host after migration is performed, and reliability of an originalapplication after the migration is performed is ensured.

For ease of understanding, the following describes, using a specificexample, a method for controlling virtual machine migration in anembodiment of the present disclosure. Referring to FIG. 5, the method inan embodiment includes the following steps.

Step 501: Detect a remaining resource amount of a second host.

An apparatus for controlling virtual machine migration may detect aresource usage amount of the second host in real time to obtain theremaining resource amount of the second host, where the resources mayinclude a memory, a network, and the like.

Step 502: Determine whether the remaining resource amount of the secondhost is greater than or equal to a preset threshold, where if theremaining resource amount of the second host is greater than or equal tothe preset threshold, step 503 is executed; if the remaining resourceamount of the second host is less than the preset threshold, step 509 isexecuted.

One or more virtual machines run on the second host, and any virtualmachine running on the second host is referred to as a second virtualmachine. The apparatus for controlling virtual machine migrationdetermines whether the remaining resource amount of the second host isgreater than or equal to the preset threshold, where the presetthreshold may be preset by the apparatus for controlling virtual machinemigration according to a resource usage amount of an application runningon a virtual machine that needs to be migrated.

Step 503: Obtain information about an application running on a firstvirtual machine.

The first virtual machine runs on a first host. If the remainingresource amount of the second host is greater than or equal to thepreset threshold, it indicates that the second host may satisfy amigration requirement of the first virtual machine from a hardwareperspective. Whether the first virtual machine may be migrated to thesecond host further needs to be considered from an applicationperspective. The apparatus for controlling virtual machine migrationobtains the information about the application running on the firstvirtual machine.

The information about the application includes a type of theapplication. The type of the application includes ordinary,double-machine, and cluster. In addition, when the type of theapplication is double-machine or cluster, the information about theapplication further includes an identifier of the application. Theidentifier of the application includes an application name, a nodeidentifier, and the like. An application of an ordinary type existsindependently, and is not associated with another application. For anapplication of a double-machine type, applications are associated witheach other, and may be identified using an application name (used todetermine whether the applications are a same double-machineapplication) and a node identifier (for example, Master or Slave).Initially, associated applications run on virtual machines of twodifferent hosts. Similarly, when an application is a clusterapplication, applications are also associated with each other, and maybe identified using an application name (used to determine whether theapplications are a same cluster application) and a node identifier (forexample, a Node1d, a Node2d, or a Node3d). Initially, associatedapplications run on virtual machines of multiple different hosts. For anapplication of a double-machine type and an application of a clustertype, it is considered that identifiers of two applications match eachother only when both application names and node identifiers match eachother, where the matching herein refers to being the same orcorresponding.

Step 504: Determine whether a type of the application running on thefirst virtual machine is ordinary, where if the type of the applicationrunning on the first virtual machine is ordinary, step 505 is executed;if the type of the application running on the first virtual machine isnot ordinary, step 507 is executed.

Step 505: Determine that no application associated with the applicationrunning on the first virtual machine runs on a second virtual machine.

When the type of the application running on the first virtual machine isordinary, the application exists independently, and no applicationassociated with the application runs on the second virtual machine, thatis, migration of the first virtual machine does not affect reliabilityof the application.

Step 506: Migrate the first virtual machine to the second host.

When the type of the application running on the first virtual machine isordinary, the second host may serve as a protection host of the firstvirtual machine running on the first host; and when the first hostbecomes faulty, or the first virtual machine needs to be migrated inanother situation, the first virtual machine may be migrated to thesecond host.

Step 507: When the type of the application running on the first virtualmachine is not ordinary, it may be determined that the type of theapplication running on the first virtual machine is double-machine orcluster.

Regardless of whether type of the application running on the firstvirtual machine is double-machine or cluster, when migration on thefirst virtual machine is being performed, a reliability problem of theapplication that originally runs on the first virtual machine after themigration is performed needs to be considered.

Step 508: Determine whether an identifier, matching an identifier of theapplication running on the first virtual machine, of an applicationrunning on the second virtual machine exists, where if the identifierexists, step 509 is executed; if the identifier does not exist, step 505is executed.

Step 509: Reject to migrate the first virtual machine to the secondhost.

When an identifier of any application running on a virtual machine onthe second host matches the identifier of the application running on thefirst virtual machine, it indicates that after the first virtual machineis migrated to the second host, different virtual machines on which anassociated application runs run on the second host. Migrating the firstvirtual machine to the second host affects the reliability of theapplication that originally runs on the first virtual machine.Considering from an application perspective, the second host is notsuitable for serving as a protection host of the first virtual machine.The apparatus for controlling virtual machine migration rejects tomigrate the first virtual machine to the second host.

The following provides description using an example of an actualapplication, which is shown in the following table:

Host Virtual machine Application type Node identifier First host Virtualmachine A1 Ordinary / Virtual machine A2 Cluster Node1d Second hostVirtual machine B1 Cluster Node2d Virtual machine B2 Double-machineSlave

The virtual machine A1 and the virtual machine A2 run on the first host,and the virtual machine B1 and the virtual machine B2 run on the secondhost. Assuming that only one application runs on each virtual machine,and a type of an application running on the virtual machine A1 isordinary, when a remaining resource amount of the second host satisfiesa preset condition, the second host may serve as a protection host ofthe virtual machine A1; and when there is a need, the virtual machine A1may be migrated to the second host. When a type of an applicationrunning on the virtual machine A2 is cluster, and a type of anapplication running on the virtual machine B1 is also cluster, assumingthat the two applications are a same cluster application, that is, namesof the two applications are the same, the node identifier Node2d matchesthe node identifier Node1d, that is, an application associated with theapplication running on the virtual machine A2 runs on the virtualmachine B1 running on the second host. In this case, the second hostcannot serve as a protection host of the virtual machine A2, and anapparatus for controlling virtual machine migration rejects to migratethe virtual machine A2 to the second host.

In this embodiment, when an apparatus for controlling virtual machinemigration needs to migrate a first virtual machine to a second host,whether the second host satisfies a migration condition is consideredfrom a hardware perspective, and whether the second host satisfies themigration condition is also considered from an application perspective.Only when a remaining resource amount of the second host satisfies apreset condition, and no application associated with an applicationrunning on the first virtual machine runs on all virtual machines on thesecond host, the first virtual machine is migrated to the second host.Therefore, different virtual machines on which an associated applicationruns are prevented from running on a same host after migration isperformed, and reliability of an original application after themigration is performed is ensured.

In addition, it should be noted that in the several embodiments providedin this application, it should be understood that the disclosed system,apparatus, and method may be implemented in other manners. For example,the described apparatus embodiment is merely exemplary. For example, theunit division is merely logical function division and may be otherdivision in actual implementation. For example, a plurality of units orcomponents may be combined or integrated into another system, or somefeatures may be ignored or not performed. In addition, the displayed ordiscussed mutual couplings or direct couplings or communicationconnections may be implemented using some interfaces. The indirectcouplings or communication connections between the apparatuses or unitsmay be implemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected according toactual needs to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of the presentdisclosure may be integrated into one processing unit, or each of theunits may exist alone physically, or two or more units are integratedinto one unit. The integrated unit may be implemented in a form ofhardware, or may be implemented in a form of a software functional unit.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions of the presentdisclosure essentially, or the part contributing to the prior art, orall or some of the technical solutions may be implemented in the form ofa software product. The software product is stored in a storage mediumand includes several instructions for instructing a computer device(which may be a personal computer, a server, a network device, or thelike) to perform all or some of the steps of the methods described inthe embodiments of the present disclosure. The foregoing storage mediumincludes any medium that can store program code, such as a universalserial bus (USB) flash drive, a removable hard disk, a read-only memory(ROM), a RAM, a magnetic disk, or an optical disc.

The foregoing embodiments are merely intended for describing thetechnical solutions of the present disclosure, but not for limiting thepresent disclosure. Although the present disclosure is described indetail with reference to the foregoing embodiments, persons of ordinaryskill in the art should understand that they may still makemodifications to the technical solutions described in the foregoingembodiments or make equivalent replacements to some technical featuresthereof, without departing from the spirit and scope of the technicalsolutions of the embodiments of the present disclosure.

What is claimed is:
 1. An apparatus for controlling virtual machinemigration, comprising: a memory; and a processor coupled to the memoryand configured to: obtain information about an application running on afirst virtual machine when a remaining resource amount of a second hostis greater than or equal to a preset threshold, the first virtualmachine running on a first host, and the information about theapplication including an application type comprising double-machine orcluster; migrate the first virtual machine to the second host when noapplication associated with the application running on the first virtualmachine runs on a second virtual machine, the second virtual machinebeing any virtual machine running on the second host; and reject tomigrate the first virtual machine to the second host when an applicationrunning on the second virtual machine associated with the applicationrunning on the first virtual machine exists.
 2. The apparatus of claim1, wherein the information about the application further comprises anidentifier of the application.
 3. The apparatus of 2, wherein theprocessor is further configured to determine that an application runningon the second virtual machine associated with the application running onthe first virtual machine exists when an identifier of the applicationrunning on the second virtual machine matches an identifier of theapplication running on the first virtual machine.
 4. The apparatus ofclaim 2, wherein the processor is further configured to determine thatno application associated with the application running on the firstvirtual machine runs on the second virtual machine when an identifier ofthe application running on the second virtual machine does not match anidentifier of the application running on the first virtual machine. 5.The apparatus of claim 1, wherein the processor is further configured toreject to migrate the first virtual machine to the second host when theremaining resource amount of the second host is less than the presetthreshold.
 6. A method for controlling virtual machine migration,comprising: obtaining information about an application running on afirst virtual machine when a remaining resource amount of a second hostis greater than or equal to a preset threshold, the first virtualmachine running on a first host, and the information about theapplication including an application type comprising double-machine orcluster; migrating the first virtual machine to the second host when noapplication associated with the application running on the first virtualmachine runs on a second virtual machine, the second virtual machinebeing any virtual machine running on the second host; and rejecting tomigrate the first virtual machine to the second host when an applicationrunning on the second virtual machine associated with the applicationrunning on the first virtual machine exists.
 7. The method of claim 1,wherein the information about the application further comprises anidentifier of the application.
 8. The method of claim 7, furthercomprising determining that an application running on the second virtualmachine associated with the application running on the first virtualmachine exists when an identifier of the application running on thesecond virtual machine matches an identifier of the application runningon the first virtual machine.
 9. The method of claim 7, furthercomprising determining that no application associated with theapplication running on the first virtual machine runs on the secondvirtual machine when an identifier of the application running on thesecond virtual machine does not match an identifier of the applicationrunning on the first virtual machine.
 10. The method of claim 6, furthercomprising rejecting to migrate the first virtual machine to the secondhost when the remaining resource amount of the second host is less thanthe preset threshold.
 11. An apparatus for controlling virtualapplication node migration, comprising: a memory; and a processorcoupled to the memory and configured to: obtain information about anapplication running on a first virtual application node when a remainingresource amount of a second host is greater than or equal to a presetthreshold, the first virtual application node running on a first host,and the information about the application including an application typecomprising double-machine or cluster; migrate the first virtualapplication node to the second host when no application associated withthe application running on the first virtual application node runs on asecond virtual application node, the second virtual application nodebeing any virtual application node running on the second host; andreject to migrate the first virtual application node to the second hostwhen an application running on the second virtual application nodeassociated with the application running on the first virtual applicationnode exists.
 12. The apparatus of claim 11, wherein the informationabout the application further comprises an identifier of theapplication.
 13. The apparatus of claim 12, wherein the processor isfurther configured to determine that an application running on thesecond virtual application node associated with the application runningon the first virtual application node exists when an identifier of theapplication running on the second virtual application node matches anidentifier of the application running on the first virtual applicationnode.
 14. The apparatus of claim 12, wherein the processor is furtherconfigured to determine that no application associated with theapplication running on the first virtual application node runs on thesecond virtual application node when an identifier of the applicationrunning on the second virtual application node does not match anidentifier of the application running on the first virtual applicationnode.
 15. The apparatus of claim 11, wherein the processor is furtherconfigured to reject to migrate the first virtual application node tothe second host when the remaining resource amount of the second host isless than the preset threshold.
 16. A method for controlling virtualapplication node migration, comprising: obtaining information about anapplication running on a first virtual application node when a remainingresource amount of a second host is greater than or equal to a presetthreshold, the first virtual application node running on a first host,and the information about the application including an application typecomprising double-machine or cluster; migrating the first virtualapplication node to the second host when no application associated withthe application running on the first virtual application node runs on asecond virtual application node, wherein the second virtual applicationnode being any virtual application node running on the second host;rejecting to migrate the first virtual application node to the secondhost when an application running on the second virtual application nodeassociated with the application running on the first virtual applicationnode exists.
 17. The method of claim 11, wherein the information aboutthe application further comprises an identifier of the application. 18.The method claim 17, further comprising determining that an applicationrunning on the second virtual application node associated with theapplication running on the first virtual application node exists when anidentifier of the application running on the second virtual applicationnode matches an identifier of the application running on the firstvirtual application node.
 19. The method of claim 17, further comprisingdetermining that no application associated with the application runningon the first virtual application node runs on the second virtualapplication node when an identifier of the application running on thesecond virtual application node does not match an identifier of theapplication running on the first virtual application node.
 20. Themethod of claim 16, further comprising rejecting to migrate the firstvirtual application node to the second host when the remaining resourceamount of the second host is less than the preset threshold.